<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        
        * {
            padding: 0;
            margin: 0;
        }
        
        body {
            width: 100%;
            height: 100%;
        }
        
        footer {
            height: 30px;
            width: 100%;
            background-color: #cccccc;
            position: fixed;
            left: 0;
            bottom: 0;
        }
        
        footer ul {
            list-style: none;
            height: 100%;
            display: flex;
            justify-content: space-between;
        }
        
        footer ul li {
            text-align: center;
            width: 33%;
            line-height: 30px;
        }
        
        .active {
            background-color: red;
        }
    </style>
</head>


<body>

    <div id="box">
        <template>
            <component :is="currentText"></component>
            <footer class="tabBar">
                <ul>
                    <li @click="currentText='home'" :class="currentText=='home' ? 'active' : '' ">首页</li>
                    <li @click="currentText='goods'" :class="currentText=='goods' ? 'active' : '' ">商品</li>
                    <li @click="currentText='detail'" :class="currentText=='detail' ? 'active' : '' ">详情</li>
                </ul>
            </footer>
        </template>

    </div>
    <script>
        Vue.component("home", {
            template: `
                <div>
                    <h1>首页</h1>
                </div>
            `
        })
        Vue.component("goods", {
            template: `
                <h1>商品</h1>
            `
        })
        Vue.component("detail", {
            template: `
                <h1>详情</h1>
            `
        })


        const vm = new Vue({
            el: "#box",
            data: {
                currentText: "home"
            }

        })
    </script>
</body>

</html>